<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:wh="http://java.sun.com/jsf/composite/wh"
	xmlns:p="http://primefaces.org/ui">
<h:body>
	<ui:composition template="template/companyTemplate.xhtml">
		<ui:define name="companyContent">
				<h1>Company Market Analysis</h1>
				<h:form id="marketAnalysis" styleClass="horizontal_full">
				
					<p>
						On this page you can decide if you want to buy a specific reports. 
						There are specific market reports about the whole market (customers) and also about your competitors. 
					</p>

				<p:panel header="Market analysis report information"
					toggleable="true" collapsed="true">
					You can choose between 3 different report types. There you can find information about the market (customers) and your competitors. 
					<br />
					<br />
					Small report: Number of companies, number of agents, number of provided products, number of different products provided, Summed up company decisions and results (revenue, expenses, marketing, personal, R&amp;D), Preferences (quality, price, image) of random 33% of the agents
					<br />
					<br />
					Middle report: Small report and additional info, Number of sold products per company, Exact company decisions and results of random 50% of the companies (revenue, expenses, marketing, personal, R&amp;D), Preferences (quality, price, image) of random 66% of the agents
					<br />
					<br />
					Large report: Middle report and additional information, Preferences (quality, price, image) of all (100%) the agents and the average preferences, Which agent has chosen which product, Provided company products: selling price and how often they have been sold
				</p:panel>

				<h:panelGrid columns="1" styleClass="transparentWidget">
					
						<h:outputText value="Choose a market analyisis report: "/>
						<h:panelGrid columns="2">
						<p:selectOneMenu value="#{companyMBean.selectedReportOption}">
							<f:selectItem itemLabel="Select report-type" itemValue="" />
							<f:selectItems value="#{companyMBean.reportOptions}" var="report"
								itemLabel="#{report.reportTypeName} (#{report.reportPrice})" itemValue="#{report.id}" />
							<!-- <p:ajax update="selComp" event="change" listener="#{companyMBean.actionSpying}"/> -->
						</p:selectOneMenu>

						<p:commandButton value="Add Report"
							actionListener="#{companyMBean.saveMarketAnalysisDecision}" update="compRoundReports,marketAnalysis"/>
						</h:panelGrid>
						<!--  
						<h:panelGrid columns="2">
						<p:selectOneMenu id="selComp" required="true" requiredMessage="If you want to generate a spying report then please choose a company." disabled="#{!companyMBean.spying}" value="#{companyMBean.selectedCompetitorID}">
							<f:selectItem itemLabel="Select competitor" itemValue="" />
							<f:selectItems value="#{companyMBean.competitorList}" var="user"
								itemLabel="#{user.nickname}" itemValue="#{user.id}" />
						</p:selectOneMenu>
						
						</h:panelGrid>
						-->
					</h:panelGrid>
					<p:dataTable id="compRoundReports" var="repDec"
							value="#{companyMBean.crDecRes.reportDecisions}" selectionMode="single"
							rowKey="#{repDec.id}" rendered="#{companyMBean.reportDecisionTableRendered}"
							paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
							rowsPerPageTemplate="10,25,50,100" paginator="true" rows="10">

							<f:facet name="header">
					            Selected reports to buy
					        </f:facet>
					        
					        <p:column headerText="Delete report">
								<p:commandButton id="removeBtn" icon="ui-icon-trash" title="Delete Report"
									action="#{companyMBean.actionDeleteRepDec}"
									update="compRoundReports">
									<f:setPropertyActionListener value="#{repDec}"
										target="#{companyMBean.selectedRepDec}" />
								</p:commandButton>
							</p:column>

							<p:column headerText="Round number" sortBy="#{repDec.getRoundNumber()}">
								<h:outputText value="#{repDec.getRoundNumber()}" />
							</p:column>

							<p:column headerText="Report type" sortBy="#{repDec.report.reportTypeName}">
								<h:outputText value="#{repDec.report.reportTypeName}" />
							</p:column>

							<p:column headerText="Report price"
								sortBy="#{repDec.report.reportPrice}">
								<h:outputText value="#{repDec.report.reportPrice}" />
							</p:column>
							
							<!--  
							<p:column headerText="Target company"
								sortBy="#{companyMBean.getCompetitorName(repDec.targetCompany_Id)}">
								<h:outputText value="#{companyMBean.getCompetitorName(repDec.targetCompany_Id)}" />
							</p:column>
							-->

						</p:dataTable>
				
			</h:form>
		</ui:define>
	</ui:composition>
</h:body>
</html>